//
//  XTPictureViewController.m
//  BeautifulHome
//
//  Created by dlios on 15-5-19.
//  Copyright (c) 2015年 ACE. All rights reserved.
//

#import "XTPictureViewController.h"
#import "XTCaseCollectionViewCell.h"
@interface XTPictureViewController ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property(nonatomic, retain)UICollectionView *collectionView;
@end

@implementation XTPictureViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"案例详情";
    self.view.backgroundColor = [UIColor whiteColor];
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];

    flowLayout.itemSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height - 64);
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    flowLayout.minimumInteritemSpacing = 0;
    flowLayout.minimumLineSpacing = 0;
    flowLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 64) collectionViewLayout:flowLayout];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.pagingEnabled = YES;
    self.collectionView.contentOffset = CGPointMake(self.page * self.view.frame.size.width, 0);
    [self.view addSubview:self.collectionView];
    [_collectionView release];
    
    [self.collectionView registerClass:[XTCaseCollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
    
    [self.collectionView reloadData];
    

    
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.pictureArr.count;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    XTCaseCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];

    cell.picName = [NSString stringWithFormat:@"http://gooju.cn/dimages/%@_0_w640_h0_m0.jpg", [self.pictureArr[indexPath.row] objectForKey:@"id"]];
    
    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
